import {createStore, applyMiddleware, combineReducers, compose} from 'redux'
import createSagaMiddleware from 'redux-saga'

import rootSaga from "./saga";
import loginReducer from "./login/reducer";
import registerReducer from "./register/reducer";
import loadingReducer from "./loading/reducer";
import globalReducer from "./global/reducer";
import settingReducer from "./setting/reducer";
import menuReducer from "./menu/reducer";
import userReducer from "./user/reducer";
import dashboardReducer from "./dashboard/reducer";
import deviceReducer from "./device/reducer";
import reportReducer from "./report/reducer";
import newReducer from "./myDevice/reducer";

const sagaMiddleware = createSagaMiddleware();

const rootReducer = combineReducers({
  login: loginReducer,
  loading: loadingReducer,
  register: registerReducer,
  global: globalReducer,
  setting: settingReducer,
  menu: menuReducer,
  user: userReducer,
  dashboard: dashboardReducer,
  device: deviceReducer,
  report: reportReducer,
  new:newReducer
});

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;


const store = createStore(
  rootReducer,
  composeEnhancers(
    applyMiddleware(sagaMiddleware),
  )
);
sagaMiddleware.run(rootSaga);
export default store;
